/*

   **********************************************************************
   *                                                                    *
   * This file contains the code for an image object for a content-     *
   * based image retrieval application that "summarizes" an image and   *
   * sends the resulting image "signature" to a server for              *
   * classification. The server returns the classification result in    *
   * the form of a Web page containing example images of the input      *
   * image's category.                                                  *
   *                                                                    *
   * The image class defined here is rather specific to this particular *
   * application and is not really designed for broad reuse (just yet). *
   *                                                                    *
   **********************************************************************
*/

/*
   **********************************************************************
   *                                                                    *
   * Gist   -- content-based image retrieval application for the gPhone *
   *                                                                    *
   * Copyright (C) 2011 Yong Zeng                                       *
   *                                                                    *
   * This file is part of Gist.                                       *
   *                                                                    *
   * Gist is free software; you can redistribute it and/or modify it  *
   * under the terms of the GNU General Public License as published by  *
   * the Free Software Foundation; either version 2 of the License, or  *
   * (at your option) any later version.                                *
   *                                                                    *
   * Gist is distributed in the hope that it will be useful, but      *
   * WITHOUT ANY WARRANTY; without even the implied warranty of         *
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU   *
   * General Public License for more details.                           *
   *                                                                    *
   * You should have received a copy of the GNU General Public License  *
   * along with Goggle; if not, write to the Free Software Foundation,  *
   * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.       *
   *                                                                    *
   **********************************************************************
*/

//----------------------- PACKAGE SPECIFICATION -------------------------

package vision.gistcomputing ;

//------------------------------ IMPORTS --------------------------------

//------------------------- CLASS DEFINITION ----------------------------

/**
   This class illustrates the mechanics of implementing different types
   of gist estimators within the Goggle application's framework. It is
   not really a usable estimator. Instead, it serves as a base for
   copying code and then renaming and reimplementing various parts of it.
*/
// TODO: Replace GistEstimatorStub with the name of your gist estimator
// class.
class GistEstimatorStub extends GistEstimator {

//-------------------------- INITIALIZATION -----------------------------

/**
   Unfortunately, the gist estimator polymorphic factory only supports
   default constructors. If your new estimator needs to pass arguments
   to the constructor, the factory mechanism will need to be redesigned.
   But if you can get by with the default constructor, then simply
   perform whatever initialization you need over here.

   NOTE: For this stub, we don't really need to do anything in the
   constructor.
*/
// TODO: Replace GistEstimatorStub with the name of your gist estimator
// class.
private GistEstimatorStub()
{
}

//----------------- GIST VECTOR COMPUTATION ALGORITHM -------------------

/// This method applies the gist vector computation algorithm implemented
/// by this estimator on the supplied image and returns the gist vector
/// as an array of floats. All gist estimators must supply this function.
///
/// NOTE: For this stub estimator, we simply return a small array of
/// numbers. In your actual estimator you will (obviously) want to go
/// through the steps of the scene classification algorithm that produce
/// some sort of features that eventually lead to a "signature vector"
/// that somehow "summarizes" the input image.
public float[] apply(Image I)
{
   // TODO: Replace this nonsensical computation with the actual
   // algorithm your gist estimator implements.
   final int N = 100 ;
   float[] gist_vector = new float[N] ;
   for (int i = 0; i < N; ++i)
      //gist_vector[i] = (float) Math.random() ;
      gist_vector[i] = (float)(i + 1) ;
   return gist_vector ;
}

//------------------------------ FACTORY --------------------------------

/// This inner class implements a factory for producing instances of its
/// enclosing GistEstimator.
private static class Factory implements GistEstimator.Factory {

/// All gist estimator sub-factories must override this method and return
/// a concrete instance of their associated estimators.
public GistEstimator create()
{
   // TODO: Replace GistEstimatorStub here with the name of your gist
   // estimator class.
   return new GistEstimatorStub() ;
}

} // end of inner class GistEstimatorStub.Factory

// This static block ensures that the above factory gets registered with
// the GistEstimator registry. All concrete gist estimators must provide
// such a section.
static {
   // TODO: Replace GistEstimatorStub here with the name of your class.
   GistEstimator.register("GistEstimatorStub", new Factory()) ;
}

//-----------------------------------------------------------------------

} 
